﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Configuration;
using IDAL;

namespace DALFAC
{
    public class DataAccess
    {

        // Look up the DAL implementation we should be using
        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];
        private static readonly string orderPath = ConfigurationManager.AppSettings["OrdersDAL"];

        private DataAccess() { }

        public static IDAL.IAccountsDAL CreateIAccounts()
        {
            string className = path + ".AccountsDAL";
            return (IDAL.IAccountsDAL)Assembly.Load(path).CreateInstance(className);
        }

        public static IDAL.IAdminDAL CreateAdmin()
        {
            string className = path + ".AdminDAL";
            return (IDAL.IAdminDAL)Assembly.Load(path).CreateInstance(className);
        }

        public static IDAL.IAlbumDAL CreateAlbum()
        {
            string className = path + ".AlbumDAL";
            return (IDAL.IAlbumDAL)Assembly.Load(path).CreateInstance(className);
        }

        public static IDAL.IBlackListDAL CreateBlackList()
        {
            string className = orderPath + ".BlackListDAL";
            return (IDAL.IBlackListDAL)Assembly.Load(orderPath).CreateInstance(className);
        }

        public static IDAL.ICardsDAL CreateCards()
        {
            string className = path + ".CardsDAL";
            return (IDAL.ICardsDAL)Assembly.Load(path).CreateInstance(className);
        }

        public static IDAL.ICardTypeDAL CreateCardType()
        {
            string className = path + ".CardTypeDAL";
            return (IDAL.ICardTypeDAL)Assembly.Load(path).CreateInstance(className);
        }

        public static IDAL.IFollowsDAL CreateFollows()
        {
            string className = path + ".FollowsDAL";
            return (IDAL.IFollowsDAL)Assembly.Load(path).CreateInstance(className);
        }

        public static IDAL.IPhotoDAL CreatePhoto()
        {
            string className = path + ".PhotoDAL";
            return (IDAL.IPhotoDAL)Assembly.Load(path).CreateInstance(className);
        }

        public static IDAL.IUserInfoDAL CreateUserInfo()
        {
            string className = orderPath + ".UserInfoDAL";
            return (IDAL.IUserInfoDAL)Assembly.Load(orderPath).CreateInstance(className);
        }

        public static IDAL.IUserLgoinDAL CreateUserLgoin()
        {
            string className = path + ".UserLgoinDAL";
            return (IDAL.IUserLgoinDAL)Assembly.Load(path).CreateInstance(className);
        }
    }
}
